package ltd.jdsoft.cute.api.http;

import java.util.Map;

/**
 * 基于json的http响应结果
 * 
 * @author zhengzhq
 *
 */
public class RestResponse {

  // 元数据信息，调用端根据code来进行相应的业务处理
  private Meta meta;
  // 返回给调用端真实使用的数据。如果meta.code如果是500或者501，此时data为null
  private Map<String, Object> data = null;

  public static RestResponse SUCCESS = new RestResponse(Meta.SUCCESS);

  public RestResponse() {}

  public RestResponse(Meta meta) {
    this.meta = meta;
  }

  public RestResponse(Meta meta, Map<String, Object> data) {
    this.meta = meta;
    this.data = data;
  }

  public RestResponse(Map<String, Object> data) {
    this.meta = Meta.SUCCESS;
    this.data = data;
  }

  public Meta getMeta() {
    return meta;
  }

  public Map<String, Object> getData() {
    return data;
  }
}
